package jblip.resources;

import jblip.BlipClient;
import jblip.resources.Media.MediaType;

/**
 * Interface for creating resources returned by a <code>BlipClient</code>
 * instance.
 * 
 * <p>
 * The role of <code>ResourcesFactory</code> is to create new instances of
 * objects implementing <code>jblip.resources.*</code> from a given input. The
 * input is most likely to be obtained from HTTP response body, but that isn't
 * necessary and its decided by implementations of {@link BlipClient} class.
 * </p>
 * 
 * <p>
 * All methods of this interface should return <code>null</code> if a resource
 * can't be created from the input object.
 * </p>
 * 
 * @author Krzysztof Sroka
 * @since 0.1
 * @see BlipClient#setResourceFactory(ResourcesFactory)
 */
public interface ResourcesFactory {

  /**
   * Returns {@link Media} resource from the given object.
   * 
   * @param object
   *          Input object
   * @param type
   *          type of the object created
   * @return New {@link Media} object or <code>null</code> if the resource
   *         coudn't be created.
   */
  Media getMedia(Object object, MediaType type);

  /**
   * Returns {@link Transport} resource from the given object.
   * 
   * @param object
   *          Input object
   * @return New {@link Transport} object or <code>null</code> if the resource
   *         coudn't be created.
   */
  Transport getTransport(Object object);

  /**
   * Returns {@link Update} resource from the given object.
   * 
   * @param object
   *          Input object
   * @return New {@link Update} object or <code>null</code> if the resource
   *         coudn't be created.
   */
  Update getUpdate(Object object);

  /**
   * Returns {@link User} resource from the given object.
   * 
   * @param object
   *          Input object
   * @return New {@link User} object or <code>null</code> if the resource
   *         coudn't be created.
   */
  User getUser(Object object);

  /**
   * Returns {@link UserPicture} resource from the given object.
   * 
   * @param object
   *          Input object
   * @return New {@link UserPicture} object or <code>null</code> if the resource
   *         couldn't be created.
   */
  UserPicture getUserPicture(Object object);

  /**
   * Returns {@link Shortlink} resource from the given object.
   * 
   * @param object
   *          Input object
   * @return New {@link Shortlink} object or <code>null</code> if the resource
   *         coudn't be created.
   */
  Shortlink getShortlink(Object object);

  /**
   * Returns {@link Subscription} resource from the given object.
   * 
   * @param object
   *          Input object
   * @return New {@link Subscription} object or <code>null</code> if the
   *         resource coudn't be created.
   */
  Subscription getSubscription(Object object);
}
